//
//  UILabel+LX.m
//  微了个小博
//
//  Created by imera on 15/11/26.
//  Copyright (c) 2015年 imera. All rights reserved.
//

#import "UILabel+LX.h"

@implementation UILabel (LX)

// 文本自适应
- (CGSize)sizeWithString:(NSString *)string font:(UIFont *)font maxWith:(CGFloat)maxWith maxHeight:(CGFloat)maxHeight
{
    CGRect rect = [string boundingRectWithSize:CGSizeMake(maxWith, maxHeight)//限制最大的宽度和高度
                                       options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesFontLeading  |NSStringDrawingUsesLineFragmentOrigin//采用换行模式
                                    attributes:@{NSFontAttributeName: font}//传人的字体字典
                                       context:nil];
    
    return rect.size;
}
@end
